package bscorp.appbase.adapter;

import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.text.SimpleDateFormat;
import java.util.List;

import bscorp.appbase.R;
import bscorp.appbase.bmo.UserBmo;
import bscorp.appbase.model.Operate;
import bscorp.appbase.model.User;

/**
 * Created by mengweima on 2018/5/7.
 */
public class OperateAdapter extends BaseQuickAdapter<Operate, BaseViewHolder> {
    public OperateAdapter(int layoutResId, List data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, Operate item) {
        helper.setText(R.id.tv_operate_user, item.getUser() + "(" + item.getUserPhone() + ")");
        String format = "yyyy-MM-dd HH:mm:ss";
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        helper.setText(R.id.tv_operate_time, "发现时间：" + sdf.format(item.getTime()));

        switch (item.getResult()) {
            case "接单成功": {
                LinearLayout ll_operate_decs = (LinearLayout) helper.getView(R.id.ll_operate_decs);
                ll_operate_decs.setVisibility(View.GONE);
                helper.setText(R.id.tv_operate_user_trip, "维修人员");
                break;
            }
            case "工单创建成功": {
                helper.setText(R.id.tv_operate_user_trip, "操作用户");
                break;
            }
            case "检修完成": {
                helper.setText(R.id.tv_operate_user_trip, "维修人员");
                break;
            }
            case "检修失败驳回工单": {
                helper.setText(R.id.tv_operate_user_trip, "操作用户");
                break;
            }
        }
        helper.setText(R.id.tv_operate_decs, item.getDescription());
        helper.setText(R.id.tv_operate_result, item.getResult());
        helper.addOnClickListener(R.id.ll_device_item);
    }
}